package com.tsing.cloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author TheTsing
 * @version 1.0
 * @date 2021/11/8 13:42
 */
@RestController
public class OrderController {

    @Value("${server.port}")
    private String port;

    @Resource
    private RestTemplate restTemplate;

    private final String PAYMENT_URL = "http://CLOUD-PAYMENT-SERVICE";

    @GetMapping("/get/{id}")
    public List<Object> getAll(@PathVariable("id") String id) {
        System.out.println("**********" + port);
        return restTemplate.getForObject(PAYMENT_URL + "/getAll/" + id, List.class);
    }

}
